package com.gimi.cloud.jimi.dao.dao.User;

import com.gimi.cloud.jimi.dao.myMapper.MyMapper;
import com.gimi.cloud.jimi.dto.userInfo.RdUserInfoDTO;
import com.gimi.cloud.jimi.entity.userInfo.RdUserInfoEntity;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 
 * @author chendi
 * @date 2017年12月27日
 */
public interface UserInfoDao extends MyMapper<RdUserInfoEntity> {
	
	@Select("SELECT * FROM rd_user_info WHERE user_id = #{userId}")
	RdUserInfoEntity selectByUserId(@Param(value = "userId") Integer userId);

	@Select("SELECT * FROM rd_user_info WHERE card_id = #{cardId}")
	RdUserInfoEntity selectByCardId(String cardId);

	@Select("SELECT report_effection_end FROM rd_user_info WHERE user_id = #{userId}")
	RdUserInfoDTO getEffectionByUserId(@Param(value = "userId") Integer userId);

	@Select("select t.*,ru.status as status  from rd_user_info t left join rd_user ru on t.user_id = ru.user_id  ")
    List<RdUserInfoDTO> selectAllAndStatus();

	@Select("SELECT * FROM rd_user_info WHERE report_effection_end > NOW() AND user_id = #{userId}")
	RdUserInfoDTO isEffection(@Param(value = "userId") Integer userId);
}
